{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8a37a568",
   "metadata": {},
   "source": [
    "# Z变换"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "05004ec8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-4*z^-3+3*z^-4+-5*z^-5+-2*z^-6+5*z^-7+5*z^-8+-2*z^-9+-1*z^-10+8*z^-11+-3*z^-12\n"
     ]
    }
   ],
   "source": [
    "#有限长序列的z变换N1<=n<=N2的z变换表达式\n",
    "import numpy as np\n",
    "\n",
    "def chripz(N1,N2,X):\n",
    "   N = N1 - 1\n",
    "   text1 = '*z^'\n",
    "   text2 = '+'\n",
    "   for x in X:\n",
    "      N += 1\n",
    "      n = str(-N)\n",
    "      xx = str(x)\n",
    "      if N == N1:\n",
    "        Z = xx + text1 + n\n",
    "      else:\n",
    "         Z = Z + text2 + xx + text1 + n\n",
    "   print(Z)\n",
    "\n",
    "chripz(3,13,np.array([-4,3,-5,-2,5,5,-2,-1,8,-3]))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "376390fd",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
